#include <bits/stdc++.h>
using namespace std;

// #define ONLINE_JUDGE

#define int long long

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

int a, b, p;

const int N = 1e5+50;

char s[N];

int ans[N];

signed main()
{
	int t;
	scanf("%lld", &t);
	for (int kk=0; kk<t; ++kk)
	{
		scanf("%lld%lld%lld", &a, &b, &p);

		scanf("%s", s+1);
		int n = strlen(s+1);
		ans[n] = 0;
		for (int i=n-1, j; i>=1; i=j-1)
		{
			j = i;
			while (j-1>=1 && s[j-1] == s[i])
				--j;
			int cost = 0;
			if (s[i] == 'A') cost = a;
			else cost = b;
			for (int k=j; k<=i; ++k)
			{
				ans[k] = ans[i+1] + cost;
			}
		}

		for (int i=1; i<=n; ++i)
		{
			if (p >= ans[i])
			{
				printf("%lld\n", i);
				break;
			}
		}


	}
	return 0;
}